* Chinese regulator restricts sale of shares
* Cautious optimism on Greece
* Shares of Apple down for five straight sessions
* Coty falls after agreeing to buy P&G's beauty business
* Indexes close higher: Dow 0.19 pct, S&P 0.23 pct, Nasdaq 0.26 pct (Adds detail on volume)
By Noel Randewich
July 9 (Reuters) - U.S. stocks closed higher on Thursday after Wall Street found relief in Beijing's efforts to halt a rout in Chinese stocks, which lifted markets around the world.
Shares of Apple bucked the market and logged their first five-day losing streak since January as investors worried that consumers in China might have less money to spend on iPhones.
Wall Street had fallen sharply in the previous session as market turmoil in China, a rout in commodity prices, the Greek debt crisis and a major outage on the New York Stock Exchange spooked investors.
China's securities regulator, in its most drastic step yet to arrest a selloff on Chinese stock markets, banned shareholders with large stakes in listed firms from selling for the next six months.
About 30 percent has been knocked off the value of Chinese shares since mid-June. Some investors fear that the turmoil in the Chinese market could destabilize the global financial system, making it a bigger risk than the Greek crisis.
Adding to cautious optimism on Wall Street, European markets rose on hopes that Greece might be able to win a deal that could keep it in the euro zone. Greek Prime Minister Alexis Tsipras has until midnight to propose spending cut plans.
"There a relief that (China's selloff) didn't continue. There's a relief that there doesn't seem to be any belligerent tone coming out of Greece," said Steve Goldman, principal of Goldman Management in Short Hills, New Jersey.
The Dow Jones industrial average rose 33.2 points, or 0.19 percent, to end at 17,548.62. The S&P 500 gained 4.63 points, or 0.23 percent, to 2,051.31 and the Nasdaq Composite added 12.64 points, or 0.26 percent, to 4,922.40.
All three indexes earlier traded up 1 percent or more.
"There was a bit more optimism this morning and then just a general fallback as the day went on," said Giri Cherukuri, head trader at OakBrook Investments LLC, which oversees $1.3 billion in Lisle, Illinois.
Seven of the 10 major S&P 500 sectors were higher, with the financial index leading the gainers with a 0.77 percent rise.
The NYSE, which accounted for about 13 percent of the volume of U.S. stocks traded last month, said Wednesday's halt was due to a technical problem that stemmed from new software rolled out the previous evening.
U.S. second-quarter earnings season is getting under way with major U.S. banks scheduled to report next week.
Shares of Walgreens Boots Alliance, the largest U.S. drug store chain, jumped 4.24 percent after the company raised its full-year profit forecast.
Coty's shares fell 4.7 percent after Procter & Gamble agreed to sell its beauty business to the company in a deal that values the business at $12.5 billion. P&G shares dipped 0.41 percent.
Apple dropped 2.04 percent to $120.07, just over a dollar above its 200-day moving average, closely watched by traders.
On Friday, investors will look to a press conference by Federal Reserve Chair Janet Yellen for new clues about when the central bank will begin to raise interest rates for the first time since 2006.
A hike in interest rates increases the cost of borrowing, crimping corporate profit margins.
Advancing issues outnumbered declining ones on the NYSE by 1,773 to 1,284, for a 1.38-to-1 ratio on the upside; on the Nasdaq, 1,757 issues rose and 997 fell for a 1.76-to-1 ratio favoring advancers.
The benchmark S&P 500 index posted 9 new 52-week highs and 17 new lows; the Nasdaq Composite recorded 34 new highs and 84 new lows.
About 6.6 billion shares traded on all U.S. platforms, according to BATS exchange data, below the average of 7.1 billion in the past five sessions. (Additional reporting by Tanya Agrawal; Editing by James Dalgleish and Meredith Mazzilli)